/* CSS Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Variables */
:root {
    --primary-color: #0d6efd;
    --primary-hover: #0a58ca;
    --border-color: rgba(0, 0, 0, 0.125);
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 .5rem 1rem rgba(0, 0, 0, .15);
    --transition-speed: 0.2s;
}

/* General Styles */
body {
    min-height: 100vh;
    background-color: #f8f9fa;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
}

/* Cards */
.card {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    margin-bottom: 1rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
}

.card-body {
    padding: 1rem;
}

/* Form Elements */
.form-select,
.form-control {
    border-color: #dee2e6;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-select:focus,
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
}

/* Purpose Items */
.purpose-item {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color var(--transition-speed);
}

.purpose-item:hover {
    background-color: rgba(13,110,253,.1);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-speed), visibility var(--transition-speed);
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Toast Notifications */
.toast-container {
    z-index: 1056;
}

.toast {
    background-color: #fff;
    box-shadow: var(--shadow-sm);
}

/* Responsive Design */
@media (max-width: 768px) {
    .card-header {
        padding: 0.75rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .btn {
        padding: 0.375rem 0.75rem;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
    
    body {
        background-color: #fff !important;
    }
}

/* XML Preview */
pre {
    margin: 0;
    padding: 1rem;
    background-color: #1e1e1e;
    border-radius: 0 0 0.375rem 0.375rem;
}

code {
    font-family: 'SF Mono', Monaco, Menlo, Consolas, 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* XML Syntax Highlighting */
.xml-tag {
    color: #569cd6;
}

.xml-attribute {
    color: #9cdcfe;
}

.xml-string {
    color: #ce9178;
}

/* Reasons Container */
.reason-item {
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
}

.reason-key {
    color: #0d6efd;
    margin-bottom: 0.25rem;
}

.reason-explain {
    margin-bottom: 0.25rem;
}

.reason-translation {
    font-size: 0.875rem;
}

/* Multiple Select */
select[multiple] {
    height: auto;
    min-height: 120px;
}

/* Sticky Preview */
.sticky-top {
    z-index: 1020;
}

/* Empty State */
.display-6 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
    color: #6c757d;
}

/* Responsive Adjustments */
@media (max-width: 991.98px) {
    .sticky-top {
        position: relative;
        top: 0 !important;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.card {
    animation: fadeIn 0.3s ease-in-out;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1050;
}

/* Error Messages */
#error-message {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1050;
    animation: fadeIn 0.3s ease-in-out;
}

/* Hover Effects */
.btn:hover {
    transform: translateY(-1px);
}

.form-select:hover {
    border-color: #0d6efd;
}

/* Focus States */
.form-select:focus,
.form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
}

/* Card Transitions */
.card {
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
}

/* Button States */
.btn {
    transition: all 0.2s ease;
}

.btn:active {
    transform: translateY(1px);
}

/* Loading Spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* XML Preview Styles */
.preview-section {
    position: sticky;
    top: 1rem;
    height: calc(100vh - 2rem);
}

.xml-preview {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
    background-color: #1e1e1e;
    border-radius: 0.25rem;
}

/* Loading Overlay */
#loader {
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
}

/* Form Validation Styles */
.is-invalid ~ .invalid-feedback {
    display: block;
}

/* Select2 Custom Styles */
.select2-container--bootstrap-5 .select2-selection {
    border-color: #dee2e6;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Toast Styles */
.toast-container {
    z-index: 1050;
}

/* Responsive Adjustments */
@media (max-width: 991.98px) {
    .preview-section {
        position: static;
        height: auto;
        margin-top: 1rem;
    }
}

/* Dark Mode Preview */
.bg-dark pre {
    color: #e9ecef;
}

/* Copy Button Animation */
#copyXML:active {
    transform: scale(0.95);
}

/* Form Group Spacing */
.form-group + .form-group {
    margin-top: 1rem;
}

/* Card Shadow */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Purpose Item Styles */
.purpose-item {
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    user-select: none;
}

.purpose-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.purpose-item label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    display: flex;
    align-items: center;
    user-select: none;
    padding: 0 0.5rem;
}

.purpose-item input[type="checkbox"] {
    cursor: pointer;
    margin-left: 0.5rem;
    pointer-events: auto;
}

.purpose-item input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.purpose-item .label-content {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

/* Purpose Info Icon */
.purpose-info {
    color: #6c757d;
    font-size: 0.875rem;
    cursor: pointer;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.purpose-info:hover {
    color: #495057;
}

/* Tracking Switch Styles */
.tracking-switch-container {
    padding: 1rem;
}

.form-switch {
    padding-left: 2.5em;
    min-height: 2em;
    display: flex;
    align-items: center;
}

.form-switch .form-check-input {
    margin-left: -2.5em;
    width: 3em;
    height: 1.5em;
    cursor: pointer;
}

.form-switch label {
    cursor: pointer;
    user-select: none;
    margin-left: 0.5rem;
}

/* Purpose Container Spacing */
.purpose-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Description Text */
.type-description {
    color: #6c757d;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Popover Styles */
.popover {
    max-width: 300px;
}

.popover-body {
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.popover-body strong {
    display: block;
    margin-bottom: 0.5rem;
    color: #495057;
}

.popover-body strong:not(:first-child) {
    margin-top: 1rem;
}

/* Form Check Styles */
.form-check {
    padding-left: 0;
    margin-bottom: 0;
    min-height: unset;
}

.form-check-input {
    margin-left: 0;
}

.form-check-label {
    min-height: 24px;
    display: flex;
    align-items: center;
}

/* Data Collection Styles */
.data-type-card {
    margin-bottom: 1rem;
}

.data-type-card .card-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.data-type-card .purpose-item {
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.data-type-card .purpose-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.data-type-card .purpose-item label {
    margin: 0;
    cursor: pointer;
    flex: 1;
}

.data-type-card .purpose-info {
    color: #6c757d;
    font-size: 0.875rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.data-type-card .purpose-info:hover {
    color: #495057;
}

/* API Types and Data Collection Containers */
.api-purposes-container,
.data-purposes-container {
    margin: 0 -0.75rem;
}
